// pages/manage/manage.js
var network = require("../../utils/request.js")
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    customerPhone:'',
    head:'',
    nickName:'',
    realName:'',
    authStatus:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },
  initDataAuthStatus: function () {
    var that = this;
    var param = { consumerId: app.globalData.consumerid };
    network.requestLoading('POST', app.globalData.requestUrl + 'getCertificationStatusAPI', param, '加载中', function (res) {
      if (res.result == "success") {
        var authStatus = res.data.authStatus;
        var reason = res.data.reason;
        that.setData({
          authStatus: authStatus,
          reason: reason
        })

      } else {
        wx.showToast({ title: res.message, icon: 'none' })
      }
    })
  },

  initCustome:function(){
    var that = this;
    var param = {};
    network.requestLoading('POST', app.globalData.requestUrl + 'getInformationAPI', param, '加载中', function (res) {
      if (res.result == "success") {
      
        that.setData({
          customerPhone:res.data.phone
        })
        app.globalData.rule=res.data.rule;
      } else {
        wx.showToast({
          title: res.messge,
          icon: 'none'
        })
      }
    })
  },
  initUserInfo:function(){
    var that = this;
    let consumerId = app.globalData.consumerid;
    var param = { consumerId: consumerId};
    network.requestLoading('POST', app.globalData.requestUrl + 'getConsumerInfoByIdAPI', param, '加载中', function (res) {
      if (res.result == "success") {
        app.globalData.userInfo = res.data;
        that.setData({
          head: res.data.head,
          nickName: res.data.nickName,
          realName: res.data.realName
        })
      } else {
        wx.showToast({
          title: res.messge,
          icon: 'none'
        })
      }
    })
  },
  //个人信息
  modifyInformation:function(){
    wx.navigateTo({
      url: '../modifyInformation/modifyInformation',
    })
  },
  //钱包
  myWallet:function(){
    wx.navigateTo({
      url: '../wallet/wallet',
    })
  },
  //实名认证
  realName:function(){
    wx.navigateTo({
      url: '../realName/realName',
    })
  },
  //评价与心得
  evaluation:function(){
    wx.navigateTo({
      url: '../evaluation/evaluation',
    })
  },
  //意见建议
  advice:function(){
    wx.navigateTo({
      url: '../advice/advice',
    })
  },
  //平台介绍及规则
  parse:function(){
    wx.navigateTo({
      url: '../parse/parse',
    })
  },
  //联系客服
  callPhone:function(){
    wx.makePhoneCall({
      phoneNumber: this.data.customerPhone
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.initCustome();//初始化获取客服电话、平台规则
    this.initUserInfo();
    this.initDataAuthStatus();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})